 #!/usr/bin/env python3
"""
检查LoadData表结构
"""

import sys
import os
sys.path.append('.')

from backend.config.database import get_db_session
from backend.entities.load_data_new import LoadData
from datetime import datetime

def debug_load_structure():
    """检查LoadData表结构"""
    print('检查LoadData表结构...')
    
    db = get_db_session()
    
    try:
        # 获取一条负荷数据记录
        load_record = db.query(LoadData).first()
        
        if load_record:
            print(f'找到负荷数据记录: {load_record.dt}')
            print(f'记录属性: {dir(load_record)}')
            
            # 检查所有属性
            for attr in dir(load_record):
                if not attr.startswith('_'):
                    try:
                        value = getattr(load_record, attr)
                        print(f'{attr}: {value} (类型: {type(value)})')
                    except Exception as e:
                        print(f'{attr}: 无法获取值 - {e}')
        else:
            print('没有找到负荷数据记录')
            
    except Exception as e:
        print(f'调试失败: {e}')
    finally:
        db.close()

if __name__ == '__main__':
    debug_load_structure()